package se.karolinska.corticostriatal.crosshair;

import mmcorej.CMMCore;
import org.micromanager.MMStudioMainFrame;
import org.micromanager.acquisition.AcquisitionEngine;
import org.micromanager.api.ScriptInterface;
import org.micromanager.utils.ReportingUtils;

/**
 *  Add a crosshair to the life view image.  
 * 
 * @author Matthijs
 */
public class Crosshair implements org.micromanager.api.MMPlugin {
    
    
    public  static MMStudioMainFrame    gui;
    public  static CMMCore              core;
    public  static AcquisitionEngine    engine;
    
    private static CrosshairDialog      dialog;
    
   
    /**
     *  Set references to main MicroManager application objects.
     * 
     *  @param si ScriptInterface from MicroManager.
     */
    @Override
    public void setApp(ScriptInterface si) {
        gui     = (MMStudioMainFrame) si;
        core    = gui.getMMCore();
        engine  = gui.getAcquisitionEngine();
    }
    

    /**
     *  Ensure the plug-in window is visible. This means creating a new plugin
     *  JFrame if it did not yet exist, and otherwise moving it to the front.
     */
    @Override
    public void show() {
        ReportingUtils.logMessage("Showing crosshair plugin.");
        if (dialog == null) {
            dialog = new CrosshairDialog();
            dialog.setVisible(true);
        } else {
            dialog.setVisible(true);
            dialog.toFront();
        }
    }


    /**
     *  General purpose information members.
     */
    @Override public String getDescription() { return "Add a crosshair to the life image window."; }
    @Override public String getInfo()        { return "Crosshair.";      }
    @Override public String getVersion()     { return "1";               }
    @Override public String getCopyright()   { return "Matthijs Dorst";  }
    @Override public void dispose()          {                           }    
}
